//
//  StatusCell.m
//  CC
//
//  Created by Calvin on 5/18/15.
//  Copyright (c) 2015 Calvin. All rights reserved.
//

#import "StatusCell.h"
#import "StatusDetailView.h"
#import "StatusToolBar.h"
#import "StatusFrame.h"

@interface StatusCell()
@property (nonatomic,weak) StatusDetailView *detailView;
@property (nonatomic,weak) StatusToolBar *toolBar;
@end

@implementation StatusCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self =[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupDetailView];
        [self setupTooBar];
    }
    
    return self;
}

-(void)setupDetailView
{
    StatusDetailView *detailView = [[StatusDetailView alloc] init];
    [self.contentView addSubview:detailView];
    self.detailView=detailView;
}

-(void)setupTooBar
{
    StatusToolBar *toolBar =[[StatusToolBar alloc] init];
//    toolBar.backgroundColor=[UIColor grayColor];
    [self.contentView addSubview:toolBar];
    self.toolBar=toolBar;
}

-(void)setStatusFrame:(StatusFrame *)statusFrame
{
    _statusFrame=statusFrame;
    self.detailView.detailFrame=statusFrame.statusDetailFrame;
    self.toolBar.frame=statusFrame.toolBarFrame;
    self.toolBar.status=statusFrame.status;
}
+(instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"cell";
    StatusCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
            cell = [[StatusCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    cell.backgroundColor = [UIColor clearColor];
    return cell;
}
@end
